﻿var PrizeTypeJson;
var pageSize = 15;
$(document).ready(function () {

    //按照比赛名称进行 查询
    $.ajax({
        type: "post",
        data: { action: "GetList" },
        dataType: "json",
        url: "../../Ajax/PrizeTypeAjax.ashx",
        beforeSend: function () {
        },
        success: function (data) {
            if (data != null) {
                PrizeTypeJson = data.json;
                $("#seleByType").append(InitSelectByType());
                PageClickFunc(1);
            }
        },
        complete: function () {
        },
        error: function () {
        }
    });
    $("#txtSysAccount").focus(function () {
        if ($(this).val() == "输入系统账号查询") {
            $(this).val("");
        }
    });
    $("#txtSysAccount").blur(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("default"));
        }

    });
    $("#seleByType").change(function () {
        PageClickFunc(1);
    })

    $("#btnSele").click(function () {
        InitTaskName(1)
    })
})

//查询下拉框选择方法
function InitSelectByType() {
    var sel = "";
    $.each(PrizeTypeJson, function (k, v) {
        if (k == 0) {
            sel += "<option value='" + v.ID + "' selected='selected'>" + v.Name + "</option>";
        }
        else
            sel += "<option value='" + v.ID + "'>" + v.Name + "</option>";
    })
    return sel;
}
PageClickFunc = function (pageclickednumber) {
    InitTaskName(pageclickednumber);
}
function InitTaskName(pageclickednumber) {
    $.ajax({
        type: "post",
        data: { action: "Select", typeID: $("#seleByType").val(), sysAccount: $("#txtSysAccount").val() == "输入系统账号查询" ? "" : $("#txtSysAccount").val(), pageIndex: pageclickednumber, pageSize: pageSize },
        dataType: "json",
        url: "../../Ajax/szfOrderManage.ashx",
        beforeSend: function () {
        },
        success: function (data) {
            if (data != null) {
                var json = data.json;
                var pageCount = data.flag;
                var tbody = "";
                $.each(json, function (k, v) {
                    tbody += "<tr>"
                    tbody += "<td><lable name='lblName' id='" + v.ID + "'>";
                    tbody += v.Name;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblOrderAccount'>";
                    tbody += v.OrderAccount;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblIMSI'>";
                    tbody += v.IMSI;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblCardNum'>";
                    tbody += v.CardNum;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblCardPwd'>";
                    tbody += v.CardPwd;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblPrice' >";
                    tbody += v.Price;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblSzfPrice' >";
                    tbody += v.SzfPrice;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblOpName' >";
                    tbody += v.OpName;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblMerNum' >";
                    tbody += v.MerNum;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblCreateTime' >";
                    tbody += v.CreateTime;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblPayTime' >";
                    tbody += v.PayTime;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblState' >";
                    tbody += v.StateName;
                    tbody += "</label></td>";
                    tbody += "<td><lable name='lblTaskName' >";
                    tbody += v.TaskName
                    tbody += "</label></td>";
                    tbody += "</tr>"
                })
                $("#tb1").empty().append(tbody);
                $("#pager").pager({ pagenumber: pageclickednumber, pagecount: Math.ceil(pageCount / pageSize), buttonClickCallback: PageClickFunc });
            }
        },
        complete: function () {
        },
        error: function () {
        }
    });
}